<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>文件导出</title>
    <link rel="stylesheet" href="../wjdc/easyui/css/icon.css"/>
    <link rel="stylesheet" href="../wjdc/easyui/css/easyui.css"/>
    <script src="../wjdc/easyui/js/jquery.min.js"></script>
    <script src="../wjdc/easyui/js/jquery.easyui.min.js"></script>
    <script src="../wjdc/easyui/js/easyui-lang-zh_CN.js"></script>

    <script>
        $(function () {
            var height = $(window).height() - $("#title").height();

            $("#downBF").attr("style", "width:100%;height:" + height + "px");
            $("#downBF").layout("resize", {
                width: "100%",
                height: height + "px"
            });

        });
        var fromState = false;

        function wjdc_chaxun() {

            if (document.getElementById("tableCode").value.replace(/(^\s*)|(\s*$)/g, "") == ""
            ) {
                $.messager.alert('提示', '<a style="font-size: 17px;color: red">表名不能为空!</a>')
            } else if (document.getElementById("wjdc_date1").value.replace(/(^\s*)|(\s*$)/g, "") == "") {
                $.messager.alert('提示', '<a style="font-size: 17px;color: red">起始时间不能为空!</a>')
            } else if (document.getElementById("wjdc_date2").value.replace(/(^\s*)|(\s*$)/g, "") == "") {
                $.messager.alert('提示', '<a style="font-size: 17px;color: red">截止时间不能为空!</a>')
            } else if ($("#wjdc_date1").datetimebox("getValue") > $("#wjdc_date2").datetimebox("getValue")) {
                $.messager.alert('提示', '<a style="font-size: 17px;color: red">结束时间不能小于起始时间!</a>')
            } else {

                $.post("getColumnName", {bm: $("#tableCode").combobox("getText")}, function (d) {

                    var columns = [];
                    var array = new Array()
                    for (var i = 0; i < d.length; i++) {

                        array.push({field: d[i].toString(), title: d[i].toString(), width: '120', align: "center"});
                    }
                    columns.push(array);

                    $("#first_main").datagrid({
                        fitColumns: "true",
                        method: "get",
                        url: "findTableData",
                        queryParams: {
                            bm: $("#tableCode").combobox("getText"),
                            t1: $("#wjdc_date1").datetimebox("getValue"),
                            t2: $("#wjdc_date2").datetimebox("getValue")
                        },
                        singleSelect: true,
                        height: 450,
                        columns: columns,
                        toolbar: [
                            {
                                text: "<a style='font-size: 17px'>excel导出</a>",
                                iconCls: "icon-print",
                                handler: function () {
                                    excelDaoChu();
                                }
                            },
                            {
                                text: "<a style='font-size: 17px'>world导出</a>",
                                iconCls: "icon-print",
                                handler: function () {
                                    worldDaoChu();
                                }
                            },
                            {
                                text: "<a style='font-size: 17px'>txt导出</a>",
                                iconCls: "icon-print",
                                handler: function () {
                                    txtDaoChu();
                                }
                            },
                            {
                                text: "<a style='font-size: 17px'>csv导出</a>",
                                iconCls: "icon-print",
                                handler: function () {
                                    csvDaoChu();
                                }
                            },
                            {
                                text: "<a style='font-size: 17px'>rtf导出</a>",
                                iconCls: "icon-print",
                                handler: function () {
                                    rtfDaoChu();
                                }
                            },
                        ]
                    });
                });
                var tab = $('#main').tabs('getTab', 0);  // 取得第一个tab
                $('#main').tabs('update', {
                    tab: tab,
                    options: {
                        title: $("#tableCode").combobox("getText")
                    }
                });
            }
        }

        function excelDaoChu() {
            location.href = "excelDaochu";
        }

        function worldDaoChu() {
            location.href = "hbprint_world";
        }

        function txtDaoChu() {
            location.href = "txt_daochu";
        }

        function csvDaoChu() {
            location.href = "csvDaoChu";
        }
    </script>

</head>
<body>

<div id="title" style="width: 100%;height:70px;);background-size:100% 100%;">

    <table style="border-collapse:separate; border-spacing:15px;">
        <tr>
            <td>
                <a>表名:</a>
            </td>
            <td>
                <input id="tableCode" class="easyui-combobox" style="width:200px;" data-options="
                valueField: 't_id',
                textField: 't_table_name',
                url: 'findAllTable',">
            </td>

            <td>
                <input id="wjdc_date1" type="text" class="easyui-datetimebox" required="required">
            </td>

            <td>至</td>

            <td>
                <input id="wjdc_date2" type="text" class="easyui-datetimebox" required="required">
            </td>

            <td>
                <a href="javascript:void(0)" class="easyui-linkbutton"
                   iconCls="icon-search" onclick="wjdc_chaxun()">
                    <div style="font-size: 17px">查询</div>
                </a>
            </td>

        </tr>

    </table>
</div>


<div id="downBF" class="easyui-layout" style="width: 100%;height:900px">


    <div id="main" class="easyui-tabs" data-options="region:'center'">

        <div id="first_main">

        </div>

    </div>

</div>

</body>
</html>